

#define Handle long
#define PipeClientHandle Handle
#define PacketReaderHandle Handle


class ReqPipe
{
public:
	ReqPipe();
	~ReqPipe();

	void Init(string ip, int port);
	void Close();

	Handle SendReq(Handle ReadPack);

protected:

private:
	Handle m_pipeHandle;
	string m_ip;
	int m_port;
	
};

class SimpleTestReq
{
public:
	SimpleTestReq();
	~SimpleTestReq();

	int Send();
protected:

private:
	
};


enum OrderType
{
	OrderType_None = 0,
	OrderType_Buy,
	OrderType_Sell,
	OrderType_max
};

class PacketWriter
{
public:
	PacketWriter();
	~PacketWriter();

	void SetInt(int value);
	void SetLong(long data);
	void SetDouble(double data);
	void SetString(string str);
	void SetDatetime(datetime time);
	void SetRate(MqlRates &rate);

	void Open();
	void Close();

	Handle m_handle;

protected:

private:
	
};

class PacketReader
{
public:
	PacketReader();
	~PacketReader();

	void Open(Handle readerHandle);
	void Close();

	void GetInt(int &data);
	void GetLong(long &data);
	void GetDouble(double &data);
	void GetString(string &str);
	void GetDatetime(datetime &data);

protected:

private:
	Handle m_handle;
	
};


class GetActionReq
{
public:
	GetActionReq();
	~GetActionReq();
	
	void Init(ReqPipe &pipe);
	bool GetAction(MqlRates &rates[], int count);
	
	OrderType OrderArr[1024*10];
	int 	OrderLength;

protected:

private:
	ReqPipe m_pipe;
};


class GetRateInfoReq
{
public:
	GetRateInfoReq();
	~GetRateInfoReq();
	
	void Init(ReqPipe &pipe);
	bool GetRateInfo();
	
	string SymbolName;
	ENUM_TIMEFRAMES TimeFrame;
	datetime StartTime;
	datetime EndTime;
	
protected:

private:
	ReqPipe m_pipe;
};


class SendRateReq
{
public:
	SendRateReq();
	~SendRateReq();
	
	void Init(ReqPipe &pipe);
	bool SendRate(MqlRates &rates[], int offset, int count);
	
protected:

private:
	ReqPipe m_pipe;
};

